Water Jug Problem
Problem Formulation:
Each state= ordered pair {X,Y}
Where,
X= amount of water contained in Jar 1 (4 gallon capacity)
at any time.
Y=amount of water contained in Jar 2 (3 gallon capacity)
at any time.
Initial state: {0,0}
Final state: { P, 2}, Where P is any amount of water.
Production Rules: RULE 1: (X,Y)→(4,Y) [fill 4 gallon jug. Applicable if X<4]
RULE 2: (X,Y)→(X,3) [fill 3 gallon jug. Applicable if Y<3]
RULE 3: (X,Y)→(X-X1,Y) [pour some water out of 4 gallons jar]
RULE 4: (X,Y)→(X,Y-X1) [pour some water out of 3 gallons jar]
RULE 5: (X,Y)→(0,Y) [Empty 4 gallon jar]
RULE 6: (X,Y)→(X,0) [Empty 3 gallon jar]
RULE 7: (X,Y)→(4,Y-(4-X)) [Fill 4 gallon jar by pouring some water from 3 gallon jar]
RULE 8: (X,Y)→(X-(3-Y),3) [Fill 3 gallon jar by pouring some water from 4 gallon jar]
RULE 9: (X,Y)→(X+Y,0) [Empty 3 gallon jar by pouring all its water into 4 gallon jar]
RULE 10: (X,Y)→(0,X+Y) [Empty 4 gallon jar by pouring all its water into 3 gallon jar]
RULE 11: (0,2)→(2,0) [Pour 2 gallon from 3 gallon jar into 4 gallon]
RULE 12: (2,y)→(0,y) [empty the 2 gallons in 3 gallon jar on the ground]